﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
using QuangNgai.cauhinh;
using QuangNgai.nhaplieu.timkiemthongke;

namespace QuangNgai
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Configuration config = ConfigurationManager
                                    .OpenExeConfiguration(ConfigurationUserLevel.None);
            var connStr = config.ConnectionStrings
                            .ConnectionStrings["QuangNgai.Properties.Settings.lutru_UBND98Con"]
                            .ConnectionString;
            SqlConnection sqlConn = new SqlConnection(connStr);
            try
            {
                sqlConn.Open();
                sqlConn.Close();
                Application.Run(new _frmMain());
            }
            catch (Exception e)
            {
                if (e.Message.Contains("Invalid obj"))
                {
                    MessageBox.Show("Sai tên cơ sở dữ liệu!", "Lỗi kết nối cơ sở dữ liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                sqlConn.Close();
                Application.Run(new frmConnect());
            }

        }
    }
}
